package com.bt.springboot.web.proxy;

import com.bt.springboot.web.service.SmsService;
import com.bt.springboot.web.service.impl.SmsServiceImpl;

import java.lang.reflect.Proxy;

/**
 * @author zkx
 * @Date 2024/3/26 18:20
 */
public class JdkProxyFactory {

	public static Object getProxy(Object target){
		return Proxy.newProxyInstance(
				target.getClass().getClassLoader(),
				target.getClass().getInterfaces(),
				new DebugInvocationHandler(target)
		);
	}

	public static void main(String[] args) {
		SmsService smsService = (SmsService) JdkProxyFactory.getProxy(new SmsServiceImpl());
		String s = smsService.sendCode("123");
		System.out.println(s);
	}

}
